import request from '@/utils/request'

///////editor//////////////

// executeSqlNew
export function executeSqlNew(data) {
  return request({
    url: '/websql/datasource/executeSqlNew',
    method: 'post',
    data: data
  })
}

// 获取可选的数据源
export function findSqlPageDataSourceList() {
  return request({
    url: '/websql/datasource/findSqlPageDataSourceList',
    method: 'get'
  })
}


/////////////////////////////
//checkConnectName
export function checkConnectName(dbName) {
  return request({
    url: `/websql/datasource/checkConnectName/${dbName}`,
    method: 'get'
  })
}

// 数据源连接测试
export function testDatasource(data) {
  return request({
    url: '/websql/datasource/testDatasource',
    method: 'post',
    data: data
  })
}

// 查询***列表
export function listDatasource(query) {
  return request({
    url: '/websql/datasource/list',
    method: 'get',
    params: query
  })
}

// 查询***详细
export function getDatasource(dbId) {
  return request({
    url: '/websql/datasource/' + dbId,
    method: 'get'
  })
}

// 新增***
export function addDatasource(data) {
  return request({
    url: '/websql/datasource',
    method: 'post',
    data: data
  })
}

// 修改***
export function updateDatasource(data) {
  return request({
    url: '/websql/datasource',
    method: 'put',
    data: data
  })
}

// 删除***
export function delDatasource(dbAccount) {
  return request({
    url: '/websql/datasource/' + dbAccount,
    method: 'delete'
  })
}
